package han.entity;

import han.parser.Regex;

import java.sql.Timestamp;
import java.text.SimpleDateFormat;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author: Han
 * @date: 2018/7/4 15:46
 * @dscription: TODO
 */
public class FinanceProjectInfoEntity {
    private String projectId;
    private String name;
    private String fullName;
    private String website;
    private String industryTag;
    private String email;
    private String phoneNumber;
    private String address;
    private String area1;
    private String area2;
    private String intro;
    private String userMarket;
    private String productService;
    private String financeExperience;
    private String news;
    private String member;
    private Timestamp updateTime;
    private int m;

    public FinanceProjectInfoEntity() {
    }

    public FinanceProjectInfoEntity(String projectId, String name, String fullName, String website, String industryTag, String email, String phoneNumber, String address, String area1, String area2, String intro, String userMarket, String productService, String financeExperience, String news, String member, Timestamp updateTime) {
        this.projectId = projectId;
        this.name = name;
        this.fullName = fullName;
        this.website = website;
        this.industryTag = industryTag;
        this.email = email;
        this.phoneNumber = phoneNumber;
        this.address = address;
        this.area1 = area1;
        this.area2 = area2;
        this.intro = intro;
        this.userMarket = userMarket;
        this.productService = productService;
        this.financeExperience = financeExperience;
        this.news = news;
        this.member = member;
        this.updateTime = updateTime;
    }

    public Map<String, String> generateMap() {
        Map<String, String> map = new LinkedHashMap<>();
        map.put("名称", fullName);
        map.put("邮件", email);
        map.put("电话", phoneNumber);
        map.put("地区", area1);
        map.put("网站", website);
        map.put("地址", address);
        map.put("项目名称", name);
        map.put("标签", industryTag);
        map.put("项目介绍", intro);
        map.put("融资情况", financeExperience);
        String[] financeArray = financeExperience.split("\n");
        String phase = Regex.matchString(financeArray[0], "(?<=轮次:)((?!,).)*(?=,)");
        map.put("融资轮次", phase);
        String amount = Regex.matchString(financeArray[0], "(?<=金额:)((?!,).)*(?=,)");
        map.put("融资金额", amount);
        /*String amountUnit = Regex.matchString(financeArray[0], "[美元人民币日英镑马克欧]{2,3}");
        map.put("货币单位", amountUnit);*/
        StringBuilder invest = new StringBuilder(Regex.matchString(financeArray[0], "(?<=投资方:).*(?=日期)"));
        String[] invests = invest.toString().split(">,<");
        invest = new StringBuilder();
        for (String iv : invests) {
            String temp = Regex.matchString(iv, "(?<=名称:)((?!,).)*(?=,类型)");
            invest.append(temp).append(",");
        }
        map.put("投资方", invest.toString().substring(0, invest.length()));
        String date = Regex.matchString(financeArray[0], "(?<=日期:).*");
        map.put("融资时间", date);
        map.put("创始团队", member);
        map.put("相关报道", news);
        map.put("联系人姓名", "");
        map.put("头衔", "");
        map.put("手机", "");
        map.put("邮箱", "");
        map.put("微信号", "");

        return map;
    }

    public String getProjectId() {
        return projectId;
    }

    public void setProjectId(String projectId) {
        this.projectId = projectId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getFullName() {
        return fullName;
    }

    public void setFullName(String fullName) {
        this.fullName = fullName;
    }

    public String getWebsite() {
        return website;
    }

    public void setWebsite(String website) {
        this.website = website;
    }

    public String getIndustryTag() {
        return industryTag;
    }

    public void setIndustryTag(String industryTag) {
        this.industryTag = industryTag;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getUserMarket() {
        return userMarket;
    }

    public void setUserMarket(String userMarket) {
        this.userMarket = userMarket;
    }

    public String getProductService() {
        return productService;
    }

    public void setProductService(String productService) {
        this.productService = productService;
    }

    public String getFinanceExperience() {
        return financeExperience;
    }

    public void setFinanceExperience(String financeExperience) {
        this.financeExperience = financeExperience;
    }

    public String getNews() {
        return news;
    }

    public void setNews(String news) {
        this.news = news;
    }

    public String getMember() {
        return member;
    }

    public void setMember(String member) {
        this.member = member;
    }

    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    public String getFormatTime() {
        SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return df.format(updateTime);
    }

    public String getArea1() {
        return area1;
    }

    public void setArea1(String area1) {
        this.area1 = area1;
    }

    public String getArea2() {
        return area2;
    }

    public void setArea2(String area2) {
        this.area2 = area2;
    }

    @Override
    public String toString() {
        return "FinanceProjectInfoEntity{" + "projectId='" + projectId + '\'' +
                "\n name='" + name + '\'' +
                "\n fullName='" + fullName + '\'' +
                "\n website='" + website + '\'' +
                "\n industryTag='" + industryTag + '\'' +
                "\n email='" + email + '\'' +
                "\n phoneNumber='" + phoneNumber + '\'' +
                "\n address='" + address + '\'' +
                "\n area1='" + area1 + '\'' +
                "\n area2='" + area2 + '\'' +
                "\n intro='" + intro + '\'' +
                "\n userMarket='" + userMarket + '\'' +
                "\n productService='" + productService + '\'' +
                "\n financeExperience='" + financeExperience + '\'' +
                "\n news='" + news + '\'' +
                "\n member='" + member + '\'' +
                "\n updateTime=" + updateTime +
                '}';
    }

    @Override
    public int hashCode() {
        return super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        return super.equals(obj);
    }

    public int getM() {
        return m;
    }

    public void setM(int m) {
        this.m = m;
    }
}